<template>
    <div>
        <!--订阅列表-->
        <Category></Category>
        <!--内容-->
        <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
            <div class="news-list">
                <van-cell v-for="(item,index) in newsList" :key="index">
                    <div class="content">
                        <div class="top">
                            <div class="source">
                                {{item.articleSource}}
                            </div>
                            <router-link tag="div" class=more :to="{name:'details',params:{articleId:item.articleId}}">
                                更多
                                <van-icon name="arrow" />
                            </router-link>
                        </div>
                        <div class="middle">
                            <div class="title">
                                {{item.title}}
                            </div>
                            <div class="pic">
                                <img :src="item.coverImgUrl" alt="">
                            </div>
                        </div>
                        <div class="bottom-title">{{item.createTime}}</div>
                    </div>
                </van-cell>
            </div>
        </van-pull-refresh>
    </div>
</template>

<script>
    import {subscriptionDetails} from '../api/CMS-api'
    import { Toast } from 'vant';
    import Category from '../components/Category.vue'
    export default {
        created(){
            subscriptionDetails(1,10,this.$route.params.categoryId).then(res => {
                this.newsList = res.rows
            })
        },
        components:{
            Category
        },
        data(){
            return{
                newsList:[],
                isLoading: false,
                offset:0,
            }
        },
        methods:{
            onRefresh() {
                setTimeout(() => {
                    Toast('刷新成功');
                    this.isLoading = false;
                    this.count++;
                }, 1000);
            }
        }
    }
</script>

<style lang="less" scoped>
    .news-list {
        margin-bottom: 50px;
        /*margin-left: 40px;*/
        .content {
            width: 100%;
            height: 170px;
            background-color: #ffffff;
            .top {
                width: 100%;
                height: 39px;
                border-bottom: 1px solid gainsboro;
                .source {
                    line-height: 40px;
                    float: left;
                    color: skyblue;
                    font-size: 16px;
                }
                .more {
                    line-height: 40px;
                    float: right;
                }
            }
            .middle {
                width: 100%;
                height: 95px;
                margin-top: 5px;
                .title {
                    float: left;
                    width: 60%;
                    height: 100%;
                    font-size: 18px;
                }
                .pic {
                    float: right;
                    width: 35%;
                    height: 100%;
                    margin-left: 5%;
                    img {
                        width: 100%;
                        height: 100%;
                    }
                }
            }
            .bottom-title {
                width: 100%;
                height: 30px;
                color: grey;
            }
        }
    }
</style>